﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace asp.netWebFroms
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            var uid = TextBox1.Text.Trim();
            var pwds = TextBox2.Text.Trim();

            var sql = string.Format("select * from Users where Username = '{0}' and Password = '{1}'",uid,pwds);
            var com = DbHelper.GetDataTable(sql);

            if (com.Rows.Count == 1)
            {
                var row = com.Rows[0];

                var IsActived = (bool)row.ItemArray[3];
                var IsDeleted = (bool)row.ItemArray[4];


                if (IsDeleted)
                {
                    Lab.Text = "该账号已被删除哦";
                }
                else
                {
                    if (IsActived)
                    {
                        Response.Redirect("Default.aspx");
                    }
                    else {
                        Lab.Text = "账号未启用，已过期";  
                    }
                }
            }
            else
            {
                Lab.Text = "密码或账号输入错误，请重新输入";
            }

        
        }
    }
}